{extend name="public:base"}
{block name="main"}
<div class="demoTable">
  <a  href="javascript:LayerOpen('{:Url('modeladd')}');" class="layui-btn layui-btn-normal" data-type="reload" >添加模型</a>
</div>
<table class="layui-table" lay-data="{height:650,url:location.href, page:true, id:'list'}" lay-filter="table" lay-size="lg">
  <thead>
    <tr>
      <th lay-data="{field:'modelid',width:75}">ID</th>
      <th lay-data="{field:'px',width:75}">排序</th>
      <th lay-data="{field:'name'}">模型名称</th>
      <th lay-data="{field:'type'}">类型</th>
      <th lay-data="{field:'page'}">单页模板</th>
      <th lay-data="{field:'list'}">列表模板</th>
      <th lay-data="{field:'content'}">内容模板</th>
      <th lay-data="{field:'addtime'}">添加时间</th>
      <th lay-data="{fixed: 'right',toolbar: '#barDemo'}">操作</th>
    </tr>
  </thead>
</table>

<script type="text/html" id="barDemo">
  
  <a class="layui-btn layui-btn-sm" lay-event="edit">编辑</a>
   
  <a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="del">删除</a>

</script>

<script>
layui.use(['table','laydate','form'], function(){
  var table = layui.table;
  var laydate = layui.laydate;
  var form = layui.form;
   laydate.render({
      elem: '#start',
      max: 0
   });
    laydate.render({
      elem: '#end',
      max: 1
   });
  

  table.on('tool(table)', function(obj){
    var data = obj.data;

    if(obj.event === 'del'){

       Delete("{:Url('modeldel')}",{'modelid': data.modelid},obj);
      
    } else if(obj.event === 'edit'){
        LayerOpen("/admin.php/news/modeledit/modelid/"+data.modelid);
    }

  });


});

</script>
{/block}